package org.py.controller;

import org.py.service.IUsersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/users")
public class UsersController {

    @Autowired
    private IUsersService userService;

    /**
     * 获取所有用户
     * @return
     */
    @RequestMapping("/getAllUsers")
    public String getAllUsers() {
        return userService.getAllUsers();
    }

    /**
     * 根据id获取用户
     * @return
     */
    @RequestMapping("/getUserById")
    public String getUserById(@RequestBody String json) {
        return userService.getUserById(json);
    }

    /**
     * 创建用户
     * @return
     */
    @RequestMapping("/createUser")
    public String createUser(@RequestBody String json) {
        return userService.createUser(json);
    }

    /**
     * 更新用户
     * @return
     */
    @RequestMapping("/updateUser")
    public String updateUser(@RequestBody String json) {
        return userService.updateUser(json);
    }

    /**
     * 删除用户
     */
    @RequestMapping("/deleteUserByAdmin")
    public String deleteUser(@RequestBody String json) {
        return userService.deleteUser(json);
    }

    /**
     * 用户登录
     */
    @RequestMapping("/login")
    public String login(@RequestBody String json){
        return userService.login(json);
    }
}